package com.xiaodu.yaml;

import com.xiaodu.yaml.properties.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

/**
 * @author: dutianjie
 * @date: 2021/3/22
 * @version: v1.0.0
 * @description: 描述
 * @email: dutianjie@thunisoft.com
 **/
@SpringBootApplication
@EnableConfigurationProperties({UserProperties.class})
public class ApplicationStart implements CommandLineRunner {

    @Autowired
    private UserProperties userProperties;

    @Autowired
    private User2Properties demoProperties;

    @Autowired
    private PersonProperties personProperties;

    @Autowired
    private FruitsProperties fruitsProperties;

    @Autowired
    private PersonYaml personYaml;

    public static void main(String[] args) {
        SpringApplication.run(ApplicationStart.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        System.out.println(userProperties); // 使用 @configurationProperties
        System.out.println(demoProperties); // @value
        System.out.println(personProperties);// @PropertySource
        System.out.println(personYaml);// @PropertySource 配置使用 yaml
        System.out.println(fruitsProperties); // @propertySource("url")
        System.out.println("----------------------------");
    }


}
